package test.designmode.future;

/**
 * Created by linshuo on 2018/3/4.
 */
public class RealData implements Data {
    private String response;

    @Override
    public String getResult() {
        return response;
    }

    public void doRequest(String requestName) {
        String temp;
        switch (requestName) {
            case "name":
                temp = "xiaoming";
                break;
            case "age":
                temp = "21";
                break;
            case "sex":
                temp = "male";
                break;
            default:
                temp = null;

        }
        /* 模拟耗时操作 */
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        response = temp;
    }
}
